<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="HTML_TEXT_FIELD_MAX_LENGTH" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="CONTENT_LOCALES_COLLECTION_KEY" scope="page" />
<atleap:constants className="org.apache.struts.Globals" var="LOCALE_KEY" scope="page" />
<atleap:javascript formName="newsItemForm" staticJavascript="false" dynamicJavascript="true" method="validateForm" cdata="false" />
<atleap:content identifier="information" ignore="true" uri="/news/callCreateItem"/>
<atleap:messages property="newsItemInvalidDate" />
<atleap:message key="news.errors.body.nothingChecked" var="errorMessage" />
<c:set var="dontNeedCheckBoxes" value="${newsItemForm.localesMode != 'selected'}" />
<c:set var="hasCheckBoxValidation" value="hasCheckedBox(this, 'toggleAll', &#039;${errorMessage}&#039;)" />
<atleap:form action="news/callCreateItemAnnotation" method="POST" onsubmit="var isValidForm = bCancel ? true : (validateForm(this) && ${dontNeedCheckBoxes ? 'true' : hasCheckBoxValidation}); disableButtons(this, isValidForm); return isValidForm;">
	<table cellpadding="0"  cellspacing="0" border="0" class="modificationTable">
		<tr>
			<th>
				<atleap:label property="publicationDate" key="news.form.publicationDate" colon="false" helpTip="false" />
			</th>
			<td nowrap="nowrap">
				<atleap:message key="core.commons.buttons.select" var="selectMsg" />
				<html:text property="publicationDate" styleClass="text" readonly="true" />
				<atleap:calendar fieldName="document.forms['newsItemForm'].publicationDate" showYearNavigation="true" showYearNavigationInput="true">
					<img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/calendar.gif" />" border="0" height="20" width="20" alt="${selectMsg}" title="${selectMsg}"  />
				</atleap:calendar>
			</td>
		</tr>
		<tr>
			<th>
				<atleap:label property="expirationDate" key="news.form.expirationDate" colon="false" helpTip="false" />
			</th>
			<td nowrap="nowrap">
				<atleap:message key="core.commons.buttons.select" var="selectMsg" />
				<html:text property="expirationDate" styleClass="text" readonly="true" />
				<atleap:calendar fieldName="document.forms['newsItemForm'].expirationDate" showYearNavigation="true" showYearNavigationInput="true">
					<img src="<atleap:rewriteUrl href="/images/theme/${appConfig['adminCssTheme']}/calendar.gif" />" border="0" height="20" width="20" alt="${selectMsg}" title="${selectMsg}"  />
				</atleap:calendar>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<atleap:label property="title" key="news.form.title" colon="false" helpTip="true" />
			</td>
		</tr>
		<atleap:iterator items="${sessionScope[pageScope.CONTENT_LOCALES_COLLECTION_KEY]}" var="contentLocale">
			<tr>
				<th>
					<div class="languageField">
						<atleap:fieldValue valueMap="${contentLocale.title}" var="languageTitle" />
						<c:if test="${empty languageTitle}">
							<c:set var="languageTitle" value="${contentLocale.identifier}" />
						</c:if>
						*&nbsp;<atleap:message key="news.form.language" />:&nbsp;${languageTitle}
					</div>
				</th>
				<td>
					<html:text property="title(${contentLocale.identifier})" styleClass="text" maxlength="${pageScope.HTML_TEXT_FIELD_MAX_LENGTH}" />
				</td>
			</tr>
		</atleap:iterator>
	</table>

    <c:if test="${!dontNeedCheckBoxes}">
        <%-- List of annotation values for this news item --%>
        <tiles:insert definition=".core.contentLocale.selectLocales" flush="false">
            <tiles:put name="listTitleKey" value="news.item.annotation.list" direct="true" />
            <tiles:put name="nothingCheckedErrorKey" value="news.errors.annotation.nothingChecked" direct="true" />
            <tiles:put name="languageKey" value="news.form.language" direct="true" />
            <tiles:put name="checkedBoxProperty" value="annotationCheckedBox" direct="true" />
        </tiles:insert>
    </c:if>

    <atleap:iterator items="${newsItemForm.annotationMap}" var="entry">
        <html:hidden property="annotation(${entry.key})" />
    </atleap:iterator>
    <atleap:iterator items="${newsItemForm.bodyMap}" var="entry">
        <html:hidden property="body(${entry.key})" />
    </atleap:iterator>    

	<html:hidden property="uri" value="/news" />
    <html:hidden property="localesMode" />
    <atleap:cancel styleClass="button"><atleap:message key="core.commons.buttons.cancel" /></atleap:cancel>
    <atleap:submit styleClass="button"><atleap:message key="core.commons.buttons.next" /></atleap:submit>
</atleap:form>
